package cn.addr.server.message;


import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class XMLMessageUtil {

	public static File readRemoteXML(InputStream is, String path) {
		File file = new File("cache/"+path+".xml");
		OutputStream os = null;
		try {
			os = new FileOutputStream(file);
			byte buffer[] = new byte[4*1024];
			int len = 0;
			while ((len=is.read(buffer)) != -1) {
				os.write(buffer,0,len);
			}
			os.flush();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				os.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return file;
	}
}
